A. Field of the Invention
The present invention relates generally to a graphics system for a personal computer. More particularly, the present invention relates to a method and apparatus for applying specular highlighting to pixels in a polygon. Still more particularly, the present invention relates to an improved method of applying specular highlighting to a polygon based on color values in a texture map.
B. Background of the Invention
Sophisticated graphics packages have been used for some time in expensive computer aided drafting, design and simulation systems. Increased capabilities of graphic controllers and display systems, combined with standardized graphics languages, have made complex graphics functions available in even the most routine applications. For example, word processors, spread sheets and desktop publishing packages now include relatively sophisticated graphics capabilities. Three-dimensional (3D) displays have become common in games, animation, and multimedia communication and drawing packages.
The availability of sophisticated graphics in PC's has driven a demand for even greater graphic capabilities. To obtain these capabilities, graphic systems must be capable of performing more sophisticated functions in less time to process greater amounts of graphical data required by modern software applications. In particular, there is a continuing need for improvements in software algorithms and hardware implementations to draw three-dimensional objects using full color, shading, texture mapping, and transparency blending.
The development of raster display systems has dramatically reduced the overall cost and increased the capabilities of graphic systems. In a raster display system, a set of orthogonal or horizontal scan lines, each comprising a row of pixels, forms an array or grid of pixels to represent the entire screen area. The screen preferably comprises a cathode ray tube (CRT), LCD display, or the like, capable of scanning the entire pixel grid at a relatively high rate to reduce flicker. The pixel data preferably is stored in a frame buffer comprising dynamic random access memories (DRAM's), or more preferably video RAMs (VRAM's), where each pixel is represented by one or more bits depending upon the desired resolution. In many graphics systems, for example, each pixel is drawn or "rendered " with 24 bits of color information (8 bits for red, 8 bits for green, 8 bits for blue). Typical display systems are capable of drawing screens with multiple colors at a variety of screen resolutions, including resolutions of 640 pixels .times.480 pixels, 800.times.600, 1024.times.768, 1280 .times.1024, or even higher pixel value combinations, depending upon the software drivers and the hardware used.
Typically, a video controller scans and converts the pixel data in the frame buffer to provide control signals for the screen system. In particular, the video controller renders the screen pixels, typically from the top of the screen to the bottom and from left to right, converting pixel data into color intensity values for each pixel. In a color graphics system using a CRT, three separate beams are controlled for each of the primary colors, where the intensity of each of the beams is determined by the pixel value corresponding to the respective colors. A similar system is used for LCD displays.
Other improvements have been made in the hardware realm. Graphics processors and accelerators are available with software drivers that interface the host central processing unit (CPU) to the graphics processor. In general, objects to be drawn on the screen are represented by one or more polygons. Each polygon is further represented by one or more triangles. The software driver receives information for drawing the triangles on the screen, calculates certain basic parameters associated with the triangles and provides these parameters to the graphics processor. The software driver then sends a command for the graphics processor to draw the triangle into the frame buffer. A graphics processor may use interpolation techniques in which the fundamental information for the triangle to be drawn comprises a set of initial and incremental parameters. The graphics processor loads or otherwise receives the initial parameters for rendering a first pixel, and then interpolates the remaining pixels in a triangle by using the incremented parameters until the triangle is complete.
Graphics processors, such as the GD5464 manufactured by Cirrus Logic, are capable of applying texture to polygons through a process referred to as texture mapping. Texture mapping techniques generally apply a bitmapped texture image to a polygon on the screen. A texture map typically is a two dimensional array of texture elements ("texels") that define a texture such as a brick, a carpet design, the grain of wood or any other texture that might be applied to an object on a computer screen.
In addition to texture, a graphics processor may apply glare, or specular highlight, to an object. In FIG. 1, for example, the front wall 20 of a jail cell includes numerous vertical bars 22 and one or more horizontal bars 24, as well as a door 21. Each bar typically is drawn to give the appearance of metal. To enhance the realism of the metallic surface of the bars 22, the bars are drawn to create the appearance of light reflecting off the bars by adding a specular component to the texel color values of the bars. Thus, many graphics processors create specular highlighting by adding white, or some other appropriate color, to the texel value to be applied to pixels on bars 22, 24. Further, the amount of specular highlighting can be varied by varying the intensity of the specular component applied to a particular texel value.
As noted above, objects drawn on the screen typically are represented by one or more triangles. Most, if not all, graphics systems apply specular highlighting on a triangle-by-triangle basis and to every pixel within a triangle. Such systems, therefore, must define triangles for those portions of a polygon to receive specular highlighting. Thus, because specular highlighting is to be applied only to the bars 22, 24, each bar must be represented with two or more triangles, as illustrated by triangles 32, 34 in FIG. 2. Moreover, as the number of surfaces increases for which specular highlighting is to be applied, the number of triangles to represent those surfaces necessarily also increases.
If not for the need to apply specular highlighting to bars 22, 24 in FIG. 1, jail cell wall 20 could be represented by relatively few triangles, such as by two triangles 25, 26 separated by dashed line 28. A texture map representing the wall including the bars 22, 24 and door 21 could then be applied to triangles 25, 26. Known specular highlighting techniques, however, apply specular highlighting to every pixel in jail cell wall 20, without distinguishing the dark regions 27 between the bars where no specular highlighting is appropriate. The need for specular highlighting thus requires the jail cell wall 20 to be divided into numerous triangles. A downside of conventional specular highlighting techniques is that objects often must be rendered with more triangles than otherwise would be required. An increase in the number of triangles required to render an object places a heavier demand on the system memory and processor.
A graphic processor uses a number of parameters to represent each triangle. As the number or triangles required for specular highlighting increases, so does the number of parameters required to represent the triangles. As a result, more memory is required to store the parameters representing the triangles. Further, a greater processing demand is placed on the graphics processor to render a larger number of triangles required by specular highlighting.
Accordingly, it would be desirable to provide a graphics system that renders objects on the display using as few triangles as possible. Such a system would place less of a performance demand on the graphics processor, while also providing high quality graphics. Such a graphics system would be free to perform other tasks that would otherwise have to wait or be slowed down by the system as it renders triangles just for sake of applying specular highlighting. To date, no system is known that solves this problem.